<?php
/** @name : DummyController.php via KOOK-FRAMEWORK - @author : theerasak.p - @since : 13 �.�. 2554 18:48:22 - @encoding : UTF-8 */
require_once Path::interfaces("controller");
require_once Path::models("dummy");
require_once Path::managers("dummy");

class DummyController extends DummyManager implements ControllerInterface
{
	public function home()
	{

	}

	public function insert()
	{
		Console::write("Enter ".get_class($this)." -> ".__FUNCTION__);

		$instance = new DummyController();
		$instance->mapping();

		//$instance->saveManager($instance);

		Console::write("Exit ".get_class($this)." -> ".__FUNCTION__);
	}

	public function update()
	{
		Console::write("Enter ".get_class($this)." -> ".__FUNCTION__);

		$instance = new DummyController();
		$instance->mapping();
		$instance->set("dummyId",1);
		$instance = $instance->findManager($instance);
		$instance->set("dummyName","แก้ไข");
		$instance = $instance->saveManager($instance);
		echo "version of new is : ".$instance->getVersion();

		Console::write("Exit ".get_class($this)." -> ".__FUNCTION__);
	}

	public function delete()
	{
		Console::write("Enter ".get_class($this)." -> ".__FUNCTION__);

		$instance = new DummyController();
		$instance->mapping();
		$instance->set("dummyId",1);
		$instance->deleteManager($instance);

		Console::write("Exit ".get_class($this)." -> ".__FUNCTION__);
	}

	public function find()
	{
		Console::write("Enter ".get_class($this)." -> ".__FUNCTION__);

		$instance = new DummyController();
		$instance->mapping();
		$instance->set("dummyId",1);
		$instance = $instance->findManager($instance);

		if($instance!=NULL)
		{
			echo $instance->get("dummyName");
		}
		else
		{
			echo "not found";
		}

		Console::write("Exit ".get_class($this)." -> ".__FUNCTION__);
	}

	public function findAll()
	{
		Console::write("Enter ".get_class($this)." -> ".__FUNCTION__);

		$instance = new DummyController();
		$instance->mapping();
		$instanceList = $instance->findAllManager($instance);

		if($instanceList==NULL)
		{
			echo "not found";
		}
		else
		{
			foreach ($instanceList as $instance)
			{
				echo $instance->get("dummyName");//parent::view("Default");
			}
		}

		Console::write("Exit ".get_class($this)." -> ".__FUNCTION__);
	}

	public function findNative()
	{
		Console::write("Enter ".get_class($this)." -> ".__FUNCTION__);
		$instance = new DummyController();

		$instance = $instance->findNativeManager();

		if($instance!=NULL)
		{
			echo $instance['DummyUser']->get("dummyUserName");//parent::view("Default");
		}
		else
		{
			echo "not found";
		}

	}

	public function findAllNative()
	{
		Console::write("Enter ".get_class($this)." -> ".__FUNCTION__);

		$instance = new DummyController();
		$instanceList = $instance->findAllNativeManager();

		if($instanceList==NULL)
		{
			echo "not found";
		}
		else
		{
			foreach ($instanceList as $instance)
			{
				echo $instance['Dummy']->get("dummyName")." - ";//parent::view("Default");
				echo $instance['DummyUser']->get("dummyUserName")."<br/>";
			}
		}

		Console::write("Exit ".get_class($this)." -> ".__FUNCTION__);
	}

	public function findCountNative()
	{
		Console::write("Enter ".get_class($this)." -> ".__FUNCTION__);

		$instance = parent::findCountNativeManager();
		echo $instance['Custom']->get("count");

		Console::write("Exit ".get_class($this)." -> ".__FUNCTION__);
	}

	public function test()
	{
		Console::write("Enter ".get_class($this)." -> ".__FUNCTION__);

		HTML::instance("test","bbb");

		Render::view("domain/home");

		Console::write("Exit ".get_class($this)." -> ".__FUNCTION__);
	}

	public function testXML()
	{
		$instance = new DummyController();
		$instance->set("dummyId", 1);
		parent::findXMLManager($instance);
	}

}
?>